package com.atguigu.srb.common.result;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Map;

/**
 * @author Miao
 * @version 1.0.0
 * @data 2022年09月29日 18:42:18
 * @packageName com.atguigu.srb.common.result
 * @className ResponseResult
 * @describe TODO
 */

@Data
@AllArgsConstructor
public class ResponseResult<T> {
    private Integer code;
    private String message;
    private T data;

    public static <T> ResponseResult<T> success(){
        return new ResponseResult(ResponseEnum.SUCCESS.getCode(),ResponseEnum.SUCCESS.getMessage(), null);
    }
    public static <T> ResponseResult<T> success(String message){
        return new ResponseResult(ResponseEnum.SUCCESS.getCode(),message,null);
    }
    public static <T> ResponseResult<T> success(T data){
        return new ResponseResult(null,ResponseEnum.SUCCESS.getMessage(),data);
    }
    public static <T> ResponseResult<T> success(String message,T data){
        return new ResponseResult(ResponseEnum.SUCCESS.getCode(),message,data);
    }

    public static <T> ResponseResult<T> fail(){
        return new ResponseResult(ResponseEnum.FAIL.getCode(),ResponseEnum.FAIL.getMessage(), null);
    }
    public static <T> ResponseResult<T> fail(String message){
        return new ResponseResult(ResponseEnum.FAIL.getCode(),message,null);
    }
    public static <T> ResponseResult<T> fail(T data){
        return new ResponseResult(null,ResponseEnum.FAIL.getMessage(),data);
    }
    public static <T> ResponseResult<T> fail(String message,T data){
        return new ResponseResult(ResponseEnum.FAIL.getCode(),message,data);
    }

    public static <T> ResponseResult<T> result(ResponseEnum responseEnum){
        return new ResponseResult(responseEnum.getCode(),responseEnum.getMessage(),null);
    }

    public static <T> ResponseResult<T> result(ResponseEnum responseEnum,T data){
        return new ResponseResult(responseEnum.getCode(),responseEnum.getMessage(),data);
    }

    public static <T> ResponseResult<T> result(Integer code,String message){
        return new ResponseResult(code,message,null);
    }
}
